﻿namespace IBTrader.Modules
{
    using NLog;
    using System;
    using System.Threading;

    class W
    {
        #region static
        internal static void X(Logger logger, Action action, Action<string> log = null)
        {
            try
            {
                action();
            }
            catch (Exception ex)
            {
                logger.Log(typeof(W), new LogEventInfo(LogLevel.Error, logger.Name, ex.Message));
                logger.Log(typeof(W), new LogEventInfo(LogLevel.Debug, logger.Name, ex.StackTrace));
                if (log != null) log(ex.Message);
            }
        }
        internal static void Q(Logger logger, Action action)
        {
            ThreadPool.QueueUserWorkItem(delegate(object _)
            {
                X(logger, action);
            });
        }
        #endregion
    }
}